package com.lamatek.tags.google;

import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * GoogleMapOverviewTag
 * 
 * This class represents a &lt;googlemaps:overviewControl> tag. Developers should not extend this
 * class or override it's methods.
 * 
 * @author Tom Cole
 * @version 0.87
 */
public class GoogleMapOverviewTag extends TagSupport {

    int width = 200;
    int height = 200;
    int x = 0;
    int y = 0;
    boolean placed = false;
    /**
     * Overrides doStartTag() from TagSupport. Developers should not override this method.
     * 
     */
    public int doStartTag() {
        Tag tag = this;
        while (tag.getParent() != null) {
            if (tag.getParent() instanceof GoogleMapTag) {
                ((GoogleMapTag) tag.getParent()).setOverviewControl(this);
                return EVAL_PAGE;
            }
            tag = tag.getParent();
        }
        return EVAL_PAGE;
    }
    /**
     * Returns the desired height (in pixels) for the overview window.
     * 
     * @return A height in pixels
     */
    public int getHeight() {
        return height;
    }
    /**
     * Sets the desired height (in pixels) for the overview window.
     * 
     * @param height A height in pixels
     */
    public void setHeight(int height) {
        this.height = height;
    }
    /**
     * Returns the desired width (in pixels) for the overview window.
     * 
     * @return A width in pixels
     */
    public int getWidth() {
        return width;
    }
    /**
     * Sets the desired width (in pixels) for the overview window.
     * 
     * @param width A width in pixels
     */
    public void setWidth(int width) {
        this.width = width;
    }
    /**
     * Returns the desired x location (in pixels) for the overview window.
     * 
     * @return A pixel location
     */
    public int getX() {
        return x;
    }
    /**
     * Sets the desired x location (in pixels) for the overview window.
     * 
     * @param x The x location for the window
     */
    public void setX(int x) {
        this.x = x;
        placed = true;
    }
    /**
     * Returns the desired y location (in pixels) for the overview window.
     * 
     * @return A pixel location
     */
    public int getY() {
        return y;
    }
    /**
     * Sets the desired y location (in pixels) for the overview window.
     * 
     * @param y The y location for the window
     */
    public void setY(int y) {
        this.y = y;
        placed = true;
    }
    /**
     * Denotes whether or not the physical location of this overview has been 
     * physically placed, or using defaults.
     * 
     * @return true if the x and y values have been set, false if they are default.
     */
    public boolean wasPlaced() {
        return placed;
    }
}
